package org.jeecg.modules.online.auth.service.p005a;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.lang.invoke.SerializedLambda;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import org.jeecg.common.system.vo.SysPermissionDataRuleModel;
import org.jeecg.modules.online.auth.entity.OnlAuthData;
import org.jeecg.modules.online.auth.entity.OnlAuthRelation;
import org.jeecg.modules.online.auth.mapper.OnlAuthDataMapper;
import org.jeecg.modules.online.auth.mapper.OnlAuthRelationMapper;
import org.jeecg.modules.online.auth.service.IOnlAuthDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("onlAuthDataServiceImpl")
/* renamed from: org.jeecg.modules.online.auth.service.a.a */
/* loaded from: hibernate-re-3.7.1-RC.jar:org/jeecg/modules/online/auth/service/a/a.class */
public class OnlAuthDataServiceImpl extends ServiceImpl<OnlAuthDataMapper, OnlAuthData> implements IOnlAuthDataService {
    @Autowired
    private OnlAuthRelationMapper onlAuthRelationMapper;

    /* renamed from: a */
//    private static /* synthetic */ Object m508a(SerializedLambda serializedLambda) {
//        String implMethodName = serializedLambda.getImplMethodName();
//        boolean z = true;
//        switch (implMethodName.hashCode()) {
//            case 289685465:
//                if (implMethodName.equals("getAuthId")) {
//                    z = false;
//                    break;
//                }
//                break;
//        }
//        switch (z) {
//            case false:
//                if (serializedLambda.getImplMethodKind() == 5 && serializedLambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && serializedLambda.getFunctionalInterfaceMethodName().equals("apply") && serializedLambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && serializedLambda.getImplClass().equals("org/jeecg/modules/online/auth/entity/OnlAuthRelation") && serializedLambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
//                    return (v0) -> {
//                        return v0.getAuthId();
//                    };
//                }
//                break;
//        }
//        throw new IllegalArgumentException("Invalid lambda deserialization");
//    }

    @Override // org.jeecg.modules.online.auth.service.IOnlAuthDataService
    public void deleteOne(String id) {
        removeById(id);
        this.onlAuthRelationMapper.delete(new LambdaQueryWrapper<OnlAuthRelation>().eq(OnlAuthRelation::getAuthId, id));
    }

    @Override // org.jeecg.modules.online.auth.service.IOnlAuthDataService
    public List<SysPermissionDataRuleModel> queryUserOnlineAuthData(String userId, String cgformId) {
        List<SysPermissionDataRuleModel> queryRoleAuthData = ((OnlAuthDataMapper) this.baseMapper).queryRoleAuthData(userId, cgformId);
        List<SysPermissionDataRuleModel> queryDepartAuthData = ((OnlAuthDataMapper) this.baseMapper).queryDepartAuthData(userId, cgformId);
        List<SysPermissionDataRuleModel> queryUserAuthData = ((OnlAuthDataMapper) this.baseMapper).queryUserAuthData(userId, cgformId);
        HashMap hashMap = new HashMap(5);
        for (SysPermissionDataRuleModel sysPermissionDataRuleModel : queryRoleAuthData) {
            String id = sysPermissionDataRuleModel.getId();
            if (hashMap.get(id) == null) {
                hashMap.put(id, sysPermissionDataRuleModel);
            }
        }
        for (SysPermissionDataRuleModel sysPermissionDataRuleModel2 : queryDepartAuthData) {
            String id2 = sysPermissionDataRuleModel2.getId();
            if (hashMap.get(id2) == null) {
                hashMap.put(id2, sysPermissionDataRuleModel2);
            }
        }
        for (SysPermissionDataRuleModel sysPermissionDataRuleModel3 : queryUserAuthData) {
            String id3 = sysPermissionDataRuleModel3.getId();
            if (hashMap.get(id3) == null) {
                hashMap.put(id3, sysPermissionDataRuleModel3);
            }
        }
        Collection values = hashMap.values();
        if (values == null || values.size() == 0) {
            return null;
        }
        return new ArrayList(values);
    }

    @Override // org.jeecg.modules.online.auth.service.IOnlAuthDataService
    public void createAiTestAuthData(JSONObject json) {
        ArrayList arrayList = new ArrayList();
        JSONArray jSONArray = json.getJSONArray("data");
        if (jSONArray != null && jSONArray.size() > 0) {
            for (int i = 0; i < jSONArray.size(); i++) {
                arrayList.add((OnlAuthData) JSONObject.toJavaObject(jSONArray.getJSONObject(i), OnlAuthData.class));
            }
        }
        saveBatch(arrayList);
    }
}
